import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";

var _dec, _dec2, _dec3, _class, _class2;

/**
 * 个性化配置-列表 table
 * Table 的 rowKey 为 pageCode
 * 平台级的页面没有 pageId
 * @date 2018/11/20
 */
import React from 'react';
import { Table } from 'antd';
import { Bind } from 'lodash-decorators';
import { Button as ButtonPermission } from 'components/Permission';
import intl from 'utils/intl';
var DataTable = (_dec = Bind(), _dec2 = Bind(), _dec3 = Bind(), (_class = (_class2 = /*#__PURE__*/function (_React$Component) {
  _inherits(DataTable, _React$Component);

  var _super = _createSuper(DataTable);

  function DataTable() {
    var _this;

    _classCallCheck(this, DataTable);

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _this = _super.call.apply(_super, [this].concat(args));
    _this.columns = [{
      title: intl.get('cpfm.ui.model.page.pageCode').d('页面编码'),
      dataIndex: 'pageCode',
      width: 200
    }, {
      title: intl.get('cpfm.ui.model.page.description').d('页面描述'),
      dataIndex: 'description'
    }, {
      title: intl.get('cpaas.common.button.action').d('操作'),
      key: 'action',
      width: 150,
      fixed: 'right',
      render: function render(_, record) {
        var match = _this.props.match;
        return /*#__PURE__*/React.createElement("span", {
          className: "action-link"
        }, /*#__PURE__*/React.createElement(ButtonPermission, {
          type: "text",
          permissionList: [{
            code: "".concat(match.path, ".button.edit"),
            type: 'button',
            meaning: '页面自定义(租户)-新建'
          }],
          onClick: function onClick(e) {
            e.preventDefault();

            _this.handleColumnPageEditBtnClick(record);
          }
        }, intl.get('cpaas.common.button.edit').d('编辑')), /*#__PURE__*/React.createElement(ButtonPermission, {
          type: "text",
          permissionList: [{
            code: "".concat(match.path, ".button.pageDesign"),
            type: 'button',
            meaning: '页面自定义(租户)-页面设计'
          }],
          onClick: function onClick(e) {
            e.preventDefault();

            _this.handleColumnPageDesignBtnClick(record.pageCode);
          }
        }, intl.get('cpfm.ui.view.button.pageDesign').d('页面设计')));
      }
    }];
    return _this;
  }

  _createClass(DataTable, [{
    key: "handleColumnPageEditBtnClick",
    value: function handleColumnPageEditBtnClick(record) {
      var onPageEdit = this.props.onPageEdit;
      onPageEdit(record);
    }
  }, {
    key: "handleColumnPageDesignBtnClick",
    value: function handleColumnPageDesignBtnClick(pageCode) {
      var onPageDesign = this.props.onPageDesign;
      onPageDesign(pageCode);
    }
  }, {
    key: "handleStandardTableChange",
    value: function handleStandardTableChange(pagination, filtersArg, sorter) {
      var onTableChange = this.props.onTableChange;
      onTableChange({
        pagination: pagination,
        filtersArg: filtersArg,
        sorter: sorter
      });
    }
  }, {
    key: "render",
    value: function render() {
      var _this$props = this.props,
          pagination = _this$props.pagination,
          dataSource = _this$props.dataSource,
          loading = _this$props.loading;
      return /*#__PURE__*/React.createElement(Table, {
        bordered: true,
        rowKey: "pageCode",
        loading: loading,
        columns: this.columns,
        pagination: pagination,
        dataSource: dataSource,
        onChange: this.handleStandardTableChange
      });
    }
  }]);

  return DataTable;
}(React.Component), _class2.defaultProps = {
  loading: false,
  dataSource: [],
  pagination: false
}, _class2), (_applyDecoratedDescriptor(_class.prototype, "handleColumnPageEditBtnClick", [_dec], Object.getOwnPropertyDescriptor(_class.prototype, "handleColumnPageEditBtnClick"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "handleColumnPageDesignBtnClick", [_dec2], Object.getOwnPropertyDescriptor(_class.prototype, "handleColumnPageDesignBtnClick"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "handleStandardTableChange", [_dec3], Object.getOwnPropertyDescriptor(_class.prototype, "handleStandardTableChange"), _class.prototype)), _class));
export { DataTable as default };